package spring.code;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

public class SpringStartDemo {
    public static void main(String[] args) {

        //只做测试，实际需要配置类
//        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringStartDemo.class);
//        context.getBean("");
//
//        //
//        Resource resource = new ClassPathResource("applicationContext.xml");
//        BeanFactory beanFactory = new XmlBeanFactory(resource);
//        beanFactory.getBean("");
//
//        //
//        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
//        ac.getBean("");

        //
        ClassPathResource resource1 = new ClassPathResource("applicationContext.xml");
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
        reader.loadBeanDefinitions(resource1);
    }
}
